package com.发布订阅模式.第二种实现方式;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @className: MyGuardianListener
 * @description: 土地公公观察类
 * @author: cheetah
 * @date: 2021/11/29 16:18
 * @Version: 1.0
 */
@Component
public class MyGuardianListener implements ApplicationListener<MonkeyKingEvent> {

    @Override
    public void onApplicationEvent(MonkeyKingEvent event) {
        boolean knockGround = event.getMonkeyKing().isKnockGround();
        if(knockGround){
            MyGuardian.appear();
        }else{
            MyGuardian.seclusion();
        }
    }
}
